package image;

import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;

public class Line extends Layer 
{
	private javafx.scene.shape.Line line;
	
	public Line(String t, Paint background, Paint border, double strokeWidth, double x1, double y1, double x2, double y2) 
	{
		super(t);
		line = new javafx.scene.shape.Line(x1, y1, x2, y2);
		line.setFill(background);
		line.setStroke(border);
		line.setStrokeWidth(strokeWidth);
		
		super.setBinding();
	}

	@Override public Node getContent() 
	{
		return line;
	}

	@Override public int getWidth()
	{
		return (int) Math.abs(line.getEndX() - line.getStartX());
	}

	@Override public int getHeight()
	{
		return (int) Math.abs(line.getEndY() - line.getStartY());
	}

	@Override public int getX()
	{
		return (int) Math.min(line.getStartX(), line.getEndX());
	}

	@Override public int getY()
	{
		return (int) Math.min(line.getStartY(), line.getEndY());
	}

	@Override public void setBorder(Color c)
	{
		this.line.setStroke(c);
	}

	@Override public void setBackground(Color c)
	{
		this.line.setFill(c);
	}

	@Override public void setStroke(double width)
	{
		this.line.setStrokeWidth(width);
	}
}
